﻿Public Class TextAndMovementControl

#Region "Form Event Handlers"
    Private Sub SendTextUserControl_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        VoicesComboBox.DataSource = NabaztagLib.Lookups.Voices.GetVoicesBindingSource
        SerialNumberTextBox.Text = My.Settings.DefaultSerialNumber
        TokenTextBox.Text = My.Settings.DefaultToken
    End Sub
#End Region

#Region "Child Control Event Handlers"
    Private Sub SendButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SendButton.Click
        Dim message As NabaztagLib.Messages.IRequest = GetTextAndMovementRequest()
        ResponseTextBox.Text = NabaztagLib.MessageService.SendMessage(message).ToString
    End Sub
#End Region

#Region "Methods"
    Private Function GetTextAndMovementRequest() As NabaztagLib.Messages.IRequest
        Dim messageText As String = MessageTextBox.Text
        Dim serialNumber As String = SerialNumberTextBox.Text
        Dim token As String = Int32.Parse(TokenTextBox.Text)
        Dim voice As NabaztagLib.Lookups.VoiceEnum = NabaztagLib.Lookups.Voices.GetVoiceEnumFromDescription(VoicesComboBox.SelectedValue)
        Dim messageLifeInSeconds As String = MessageLifeNumericUpDown.Value
        Dim leftEarLocation As UInt32 = LeftEarNumericUpDown.Value
        Dim rightEarLocation As UInt32 = RightEarNumericUpDown.Value
        Dim message As New NabaztagLib.Messages.TextAndMovementRequest(serialNumber, token, messageText, voice, messageLifeInSeconds, leftEarLocation, rightEarLocation)
        Return message
    End Function
#End Region

End Class
